/**
 * Foxit Software Inc.
 * Copyright(C) 2005-2014, all rights reserved.
 * The following code is copyrighted and contains proprietary information
 * and trade secrets of Foxit Software Inc.

 * Description: Typewriter annotation
 */
define(function (require, exports, module) {
    var PDFAnnot = require('./Annot.js');
    require('../Interface.js');
    var Interface = WebPDF.Interface;
    var AnnotDataJSONFormat = WebPDF.PDFData.AnnotDataJSONFormat;

    /**
     * Enum for subtype of typewriter annotation.
     * @enum
     */
    WebPDF.PDFData.TypewriterAnnotType = {
        TYPEWRITERTYPE_TYPEWRITER: "FreeTextTypewriter",
        TYPEWRITERTYPE_TEXTBOX: "FreeTextTextbox",
        TYPEWRITERTYPE_CALLOUT: "FreeTextCallout"
    };
    /**
     * Default values for typewriter annotation.
     * @type {Object}
     */
    WebPDF.PDFData.TypewriteAnnotDefaultValue = {
    		LineHeight: 22,
    		FontHeight: 22,
    		FontSize: 20,
    		NewAnnotWidth: 5
    };

    /**
     * Enum for the form of quadding(justification) to be
     * used in displaying the annotation’s text:
     * @enum
     */
    WebPDF.PDFData.TypeWriterTextAlignStyle = {
        LEFT_JUSTIFIED: 0,
        CENTERED: 1,
        RIGHT_JUSTIFIED: 2
    };

    var PDFTypewriterAnnot = function (jsonData) {
    	PDFTypewriterAnnot.superclass.constructor.call(this, jsonData);
        $.extend(this, {
            /**
             * A name describing the intent of the free text annotation. Valid values are FreeTextCallout,
             * which means that the annotation is intended to function as a callout, and FreeTextTypeWriter, which means
             * that the annotation is intended to function as a click-to-type or typewriter object.
             * @returns {String}
             */
            getIT: function () {
                var it = this.annotJSONData[AnnotDataJSONFormat.it];
                if (it == null || it == "") {
                    it = WebPDF.PDFData.TypewriterAnnotType.TYPEWRITERTYPE_CALLOUT;
                }
                return it;
            },
            /**
             * Get font name of current annotation, default value is "Helvetica".
             * @returns {String}
             */
            getFontName: function () {
                var fontName = this.annotJSONData[AnnotDataJSONFormat.fontName];
                if (fontName == null || fontName == "") {
                    fontName = "Helvetica";
                }
                return fontName;
            },
            /**
             * Get line height of current annotation.
             * @returns {Number}
             */
            getLineHeight: function () {
                return this.annotJSONData[AnnotDataJSONFormat.lineHeight];
            },
            /**
             * Set line height of current annotation.
             * @param {Number} lineHeight
             */
            setLineHeight:function (lineHeight) {
                this.annotJSONData[AnnotDataJSONFormat.lineHeight] = lineHeight;
            },
            /**
             * Get font height of current annotation.
             * @returns {Number}
             */
            getFontHeight: function () {
                return this.annotJSONData[AnnotDataJSONFormat.fontHeight];
            },
            /**
             * Get font size of current annotation
             * @returns {Number}
             */
            getFontSize: function () {
                return this.annotJSONData[AnnotDataJSONFormat.fontSize];
            },
            /**
             * Get font color of current annotation
             * @returns {String}
             */
            getFontColor: function () {
                return this.annotJSONData[AnnotDataJSONFormat.fontColor];
            },
            /**
             * Get opacity of current annotation.
             * @returns {Number} Valid values are 0~1.0
             */
            getOpacity: function () {
                return this.annotJSONData[AnnotDataJSONFormat.opacity];
            },
            /**
             * Get a code specifying the form of quadding(justification) to be
             * used in displaying the annotation’s text
             * @returns {WebPDF.PDFData.TypeWriterTextAlignStyle}
             */
            getTextAlign: function () {
                return this.annotJSONData[AnnotDataJSONFormat.textAlign];
            },

            /**
             * Get subtype of Typerwriter annotation.
             * @returns {WebPDF.Data.AnnotType}
             */
            getSubType: function(){
                return  WebPDF.PDFData.TypewriterAnnotType.TYPEWRITERTYPE_TYPEWRITER;
            }
        });
    };
    Interface.extend(PDFTypewriterAnnot, PDFAnnot);


    WebPDF.PDFData.PDFTypewriterAnnot = PDFTypewriterAnnot;
    return WebPDF.PDFData.PDFTypewriterAnnot;
});